/**
 * 
 */
package com.castillo.exam;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;
import org.hibernate.mapping.Value;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;


/**
 * Main simple sample Struts2 action
 *
 */
public class Home extends ActionSupport  
	implements ModelDriven<Provider>{

	private String message;
	private Provider provider = new Provider();
	private ProviderDAO providerDAO = new ProviderDAO();
	private List<Provider> providers = new ArrayList<Provider>();
	
	@Override
	public Provider getModel() {
		return provider;
	}
	
	
	@Override
	public void validate() {
		// TODO Auto-generated method stub
		super.validate();
		System.out.println("Main > Validate");
	}


	@Override
	public String execute() throws Exception {
		System.out.println("Main action> execute");
		message = "Main action";
		return SUCCESS;
	}
	
	/**
	 * To list all provider.
	 * @return String
	 */
	public String selectAll()
	{
		System.out.println("Main action> Select all");
		providers = providerDAO.selectAll();
		System.out.println("Main action> Select all DAO done");
		message =String.valueOf(providers.size());
		return SUCCESS;
	}
	

	
	

	
	/**
	 * @return the message
	 */
	public String getMessage() {
		return message;
	}

	/**
	 * @param message the message to set
	 */
	public void setMessage(String message) {
		this.message = message;
	}

	


	
}
